
let ycmjGame = require('../../data/YcmjGame');
cc.Class({
    extends: cc.Component,

    properties: {
       
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this._roomInfo = {
            gameNum:8,
            isCanBP:1,
            baseScore:1,
            maxSeatNum:4
        }
    },

    start () {

    },
    gameNum(e,c){
        this._roomInfo.gameNum =  parseInt(c);

    },
    isCanBP(e,c){
        this._roomInfo.isCanBP =  parseInt(c);
    },
    baseScore(e,c){
        this._roomInfo.baseScore =  parseInt(c);
    },
    maxSeatNum(e,c){
        this._roomInfo.maxSeatNum =  parseInt(c);
    },
    ok_btn(e,c){
        pomelo.request('hall.hallHandler.creatRoom',this._roomInfo,function(res){
            if(res.code != -5){
                let tid = res.msg.tid;
                pomelo.request('hall.hallHandler.joinRoom',{tid:tid},function(res){
                    if(res.code != -5 && res.code != 500){
                        console.log('res.msg----hall.hallHandler.joinRoom->',res.msg);
                        let curgame = ycmjGame.getInstance(res.msg);
                        if(curgame){
                            game.curGame = curgame;
                            cc.director.loadScene('Ycmj');
                        };
                    }else{

                    }
                });
            }else{

            }
        });
    },
    back_btn(){
        this.node.destroy();
    }

    // update (dt) {},
});
